namespace YXShop.ExcelLite
{
    using System;
    using System.ComponentModel;

    internal class GemBoxLicenseProvider : LicenseProvider
    {
        private static Random rndGen = new Random();

        public override License GetLicense(LicenseContext context, Type type, object instance, bool allowExceptions)
        {
            ExcelFile file = instance as ExcelFile;
            if (file == null)
            {
                if (allowExceptions)
                {
                    throw new Exception("Internal error: Unrecognized caller.");
                }
                return null;
            }
            file.HashFactorA = rndGen.Next(0x458, 0x3117);
            file.HashFactorB = file.HashFactorA - 150;
            return new GemBoxLicense("Valid");
        }
    }
}

